package com.ymatou.userservice.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.ymatou.userservice.parameter.SellerOnlineStatusTimeRangeQueryRequestBean;
import com.ymatou.userservice.service.SellerOnlineStatusTimeRangeQueryRequestCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;
/**
*seller在线状态
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_SellerOnlineStatusTimeRangeQueryRequest{
	private static SellerOnlineStatusTimeRangeQueryRequestBean selleronlinestatustimerangequeryrequestBean;
	private static SellerOnlineStatusTimeRangeQueryRequestCall selleronlinestatustimerangequeryrequestCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("seller在线状态");
	}

	@Before
	public void caseUp() {
		selleronlinestatustimerangequeryrequestBean=new SellerOnlineStatusTimeRangeQueryRequestBean();
		selleronlinestatustimerangequeryrequestCall=new SellerOnlineStatusTimeRangeQueryRequestCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(selleronlinestatustimerangequeryrequestCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SellerOnlineStatusTimeRangeQueryRequest_001() {
		Logger.start(true,"查询seller在线状态成功");
		try {
			selleronlinestatustimerangequeryrequestBean.setIsStatsDetails(true);
			selleronlinestatustimerangequeryrequestBean.setStartTime(YMTDateUtil.getBeforeOrNextDay(-100));
			selleronlinestatustimerangequeryrequestBean.setEndTime(YMTDateUtil.getBeforeOrNextDay(1));
			selleronlinestatustimerangequeryrequestCall.setData(selleronlinestatustimerangequeryrequestBean);
			selleronlinestatustimerangequeryrequestCall.callService();
			Logger.verifyEquals("true", selleronlinestatustimerangequeryrequestCall.getString("Success"), "验证Success");
			JsonArray list = selleronlinestatustimerangequeryrequestCall.getJsonObject().get("Result").getAsJsonArray();
			for (JsonElement jsonElement : list) {
				//验证元素类型正确，错误会抛出异常
				Logger.debug("StatusCount:"+jsonElement.getAsJsonObject().get("StatusCount").getAsInt());
				Logger.debug("UserId:"+jsonElement.getAsJsonObject().get("UserId").getAsInt());
				Logger.debug("Status:"+jsonElement.getAsJsonObject().get("Status").getAsString());
				Logger.debug("StartTime:"+jsonElement.getAsJsonObject().get("StartTime").getAsString());
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_SellerOnlineStatusTimeRangeQueryRequest_002() {
		Logger.start(true,"不输入IsStatsDetails，默认false");
		try {
			selleronlinestatustimerangequeryrequestBean.setStartTime(YMTDateUtil.getBeforeOrNextDay(-100));
			selleronlinestatustimerangequeryrequestBean.setEndTime(YMTDateUtil.getBeforeOrNextDay(1));
			selleronlinestatustimerangequeryrequestCall.setData(selleronlinestatustimerangequeryrequestBean);
			selleronlinestatustimerangequeryrequestCall.callService();
			Logger.verifyEquals("true", selleronlinestatustimerangequeryrequestCall.getString("Success"), "验证Success");
			JsonArray list = selleronlinestatustimerangequeryrequestCall.getJsonObject().get("Result").getAsJsonArray();
			for (JsonElement jsonElement : list) {
				//验证元素类型正确，错误会抛出异常
				Logger.debug("StatusCount:"+jsonElement.getAsJsonObject().get("StatusCount").getAsInt());
				Logger.debug("UserId:"+jsonElement.getAsJsonObject().get("UserId").getAsInt());
				Logger.debug("Status:"+jsonElement.getAsJsonObject().get("Status").getAsString());
				Logger.debug("StartTime:"+jsonElement.getAsJsonObject().get("StartTime").getAsString());
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_SellerOnlineStatusTimeRangeQueryRequest_003() {
		Logger.start(true,"不输入参数，返回默认结果");
		try {
			selleronlinestatustimerangequeryrequestCall.setData(selleronlinestatustimerangequeryrequestBean);
			selleronlinestatustimerangequeryrequestCall.callService();
			Logger.verifyEquals("true", selleronlinestatustimerangequeryrequestCall.getString("Success"), "验证Success");
			JsonArray list = selleronlinestatustimerangequeryrequestCall.getJsonObject().get("Result").getAsJsonArray();
			for (JsonElement jsonElement : list) {
				//验证元素类型正确，错误会抛出异常
				Logger.debug("StatusCount:"+jsonElement.getAsJsonObject().get("StatusCount").getAsInt());
				Logger.debug("UserId:"+jsonElement.getAsJsonObject().get("UserId").getAsInt());
				Logger.debug("Status:"+jsonElement.getAsJsonObject().get("Status").getAsString());
				Logger.debug("StartTime:"+jsonElement.getAsJsonObject().get("StartTime").getAsString());
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}